package com.itheima.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.Date;

@Mapper
public interface MemberBackendMapper {
    /**
     * 获取全部要会员
     * @return
     */
    @Select("select count(*) from t_member")
    Integer getCount();

    /**
     * 获取当前时间的新增会员人数
     * @param reportDate
     * @return
     */
    @Select("select count(*) from t_member where regTime = #{reportDate}")
    Integer getTodayNew(@Param("reportDate") Date reportDate);

    /**
     * 获取当前周的会员
     * @param beginWeek
     * @param endWeek
     * @return
     */
    @Select("select count(*) from t_member where regTime >= #{beginWeek} and regTime <= #{endWeek}")
    Integer getWeekNew(@Param("beginWeek") Date beginWeek, @Param("endWeek") Date endWeek);

    /**
     * 获取当前月的会员
     * @param beginMonth
     * @param reportDate
     * @return
     */
    @Select("select count(*) from t_member where regTime >= #{beginMonth} and regTime <= #{reportDate}")
    Integer getMonthNew(@Param("beginMonth") Date beginMonth, @Param("reportDate") Date reportDate);
}
